<template>
  <div>
    <!-- bug 反馈按钮 -->
    <div
      style="
      z-index: 1;
        position: fixed;
        right: 0;
        bottom: 50%;
          transform: translate(0,50%);
        margin: 30px;
        /*height: 300px;*/
        width: 100px;
        background-color: #f2f5f6;
        box-shadow: 0 0 6px rgba(0,0,0, .12);
        text-align: center;
        line-height: 40px;
        color: #1989fa;
      "
    >
      <el-button style="height: 100px" type="primary" @click="addIssue">BUG 反馈</el-button>
    </div>

    <!-- 添加或修改参数配置对话框 -->
    <el-dialog title="填写反馈" :visible.sync="issueDialogOpen" width="900px" append-to-body >
      <el-form ref="form" :model="issueFrom"  label-width="80px">

        <el-row>
          <el-col :span="12">
            <el-form-item label="标题" prop="title" >
              <el-input v-model="issueFrom.title" placeholder="请输入反馈标题" maxlength="200"/>
            </el-form-item>

          </el-col>
        </el-row>

        <el-form-item label="类型">
          <el-select v-model="issueFrom.type"  placeholder="选择类型">
            <el-option
              v-for="item in typeOptions"
              :key="item.dictValue"
              :label="item.dictLabel"
              :value="item.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-row>
          <el-col :span="24">
            <el-form-item label="内容" prop="content">
              <editor v-model="issueFrom.content" :min-height="192"/>
            </el-form-item>
          </el-col>
        </el-row>


      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitIssueForm">确 定</el-button>
      </div>
    </el-dialog>
  </div>

</template>

<script>
import issues from "@/api/bmService/issues";
export default {
  name: "Bug",
  data(){
    return{
      issueDialogOpen:false,
      issueFrom:{
        title:'',         //标题[<200]
        type:0,
        content:'',       //内容[<21845]
      },
      typeOptions:[
        { dictValue:0,dictLabel:'bug 🐛'},
        { dictValue:1,dictLabel:'建议 🛠'},
      ],
    }
  },
  methods:{
    addIssue(){
      this.issueDialogOpen = true
    },
    submitIssueForm(){
      issues.addIssueEveryone(this.issueFrom)
        .then(response => {
          this.$notify({
            title: '反馈成功',
            message: '感谢你的反馈，我们会尽快改进',
            type: 'success'
          });
          this.issueDialogOpen = false
        })
    }
  }

}
</script>

<style scoped>

</style>
